/*
package com.njbw.user.controller;

import cn.hutool.core.img.ImgUtil;
import com.njbw.minio.entity.CreateMultipartUploadResult;
import com.njbw.minio.entity.FileMultipartUploadReq;
import com.njbw.minio.utils.MinioTemplate;
import com.njbw.redis.util.RedisUtil;
import io.minio.messages.ListPartsResult;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private MinioTemplate minioTemplate;
    @Value("${minio.bucket}")
    private String bucket;
    @Resource
    private RedisUtil redisUtil;
    private static final String minioKey = "MINIO_UPLOAD_ID";

    @SneakyThrows
    @RequestMapping("/createMultipartUpload")
    public CreateMultipartUploadResult createMultipartUpload(@RequestBody FileMultipartUploadReq req) {
        // return  (CreateMultipartUploadResult) redisUtil.get(minioKey, req.getObjectName());
        return minioTemplate.createMultipartUpload(req);
        */
/*if (multipartUpload == null) {
            multipartUpload = minioTemplate.createMultipartUpload(req);
            redisUtil.put(minioKey, req.getObjectName(), multipartUpload);
        }
        String uploadId = multipartUpload.getUploadId();
        ListPartsResponse listPartsResponse = minioTemplate.listMultipart(bucket, req.getObjectName(), uploadId);

        return multipartUpload;*//*

    }

    @SneakyThrows
    @RequestMapping("/completeMultipartUpload")
    public void completeMultipartUpload(String objectName, String uploadId) {
        minioTemplate.completeMultipartUpload(objectName, uploadId);
        InputStream inputStream = minioTemplate.download(objectName);
        // InputStream syInputStream = minioTemplate.download("sy.png");
        if (inputStream == null) {
            return;
        }
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] bytes;
        BufferedImage sy = ImgUtil.read("C:\\Users\\qibie\\Downloads\\sy.jpg");

        ImgUtil.pressImage(inputStream, bos, sy, 0, 0, 1f);
        bytes = bos.toByteArray();
        minioTemplate.putObjectByBytes(bytes, "aaa_sy.mp4");
    }

    @SneakyThrows
    @RequestMapping("/listMultipart")
    public ListPartsResult listMultipart(String objectName, String uploadId) {
        return minioTemplate.listMultipart(bucket, objectName, uploadId).result();
    }

    @SneakyThrows
    @RequestMapping("/upload")
    public void upload(@RequestBody MultipartFile file) {
        String originalFilename = file.getOriginalFilename();
        System.out.println(originalFilename);
    }
}
*/
